package com.jyserver.common.AutoCode.jybaits.element.pc.From;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jyserver.common.utils.HelpUtils;

public class Select {

    public static String getStyle(String label, Object prop, String key, JSONArray optionsArray) {
        String validate = "";
        if (HelpUtils.isNotEmpty(prop)) {
            prop = "prop=\"" + prop + "\"";
            validate = "v-validate=\"'required|" + prop + "'\" ";
        } else {
            prop = "";
        }
        String options = "";
        try {
            for (int i = 0; i < optionsArray.size(); i++) {
                JSONObject jsonObject = JSONObject.parseObject(String.valueOf(optionsArray.get(i)));
                options = options + "<el-option label=\"" + jsonObject.get("label") + "\" value=\"" + jsonObject.get("value") + "\"></el-option>\n";
            }
        } catch (Exception e) {

        }
        try {
            return "<el-form-item label=\"" + label + "\" :label-width=\"formLabelWidth\" " + prop + ">\n" +
                    "<el-select v-model=\"Dataform." + key + "\" placeholder=\"" + "请选择"+ label + "\">\n" + options +
                    "</el-select>\n" +
                    "</el-form-item>";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}
